package com.google.code.swingonfire.component.page;

import com.google.code.swingonfire.utility.interpolation.Interpolations;

public class JPageComponentAnimations
{

    public static JPageComponentAnimation fade()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingOpacity(null, 0, 1).forwardOutgoingOpacity(null, 1, 0);
        result.backwardIncomingOpacity(null, 0, 1).backwardOutgoingOpacity(null, 1, 0);

        return result;
    }

    public static JPageComponentAnimation shrink()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingOpacity(null, 0, 1).forwardIncomingScale(null, 2, 1, 2, 1);
        result.forwardOutgoingOpacity(null, 1, 0).forwardOutgoingScale(null, 1, 0.5, 1, 0.5);

        result.backwardIncomingOpacity(null, 0, 1).backwardIncomingScale(null, 0.5, 1, 0.5, 1);
        result.backwardOutgoingOpacity(null, 1, 0).backwardOutgoingScale(null, 1, 2, 1, 2);

        return result;
    }

    public static JPageComponentAnimation horizontalFade()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingTranslate(null, 0.5, 0, 0, 0).forwardIncomingOpacity(null, 0, 1);
        result.forwardOutgoingOpacity(null, 1, 0);

        result.backwardIncomingTranslate(null, -0.5, 0, 0, 0).backwardIncomingOpacity(null, 0, 1);
        result.backwardOutgoingOpacity(null, 1, 0);

        return result;
    }

    public static JPageComponentAnimation verticalFade()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingTranslate(null, 0, 0, 0.5, 0).forwardIncomingOpacity(null, 0, 1);
        result.forwardOutgoingOpacity(null, 1, 0);

        result.backwardIncomingTranslate(null, 0, 0, -0.5, 0).backwardIncomingOpacity(null, 0, 1);
        result.backwardOutgoingOpacity(null, 1, 0);

        return result;
    }

    public static JPageComponentAnimation horizontalFadeAndShrink()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingTranslate(null, 1, 0, 0, 0).forwardIncomingScale(null, 2, 1, 2, 1)
            .forwardIncomingOpacity(null, 0, 1);
        result.forwardOutgoingTranslate(null, 0, -0.5, 0, 0).forwardOutgoingScale(null, 1, 0.5, 1, 0.5)
            .forwardOutgoingOpacity(null, 1, 0);

        result.backwardIncomingTranslate(null, -1, 0, 0, 0).backwardIncomingScale(null, 2, 1, 2, 1)
            .backwardIncomingOpacity(null, 0, 1);
        result.backwardOutgoingTranslate(null, 0, 0.5, 0, 0).backwardOutgoingScale(null, 1, 0.5, 1, 0.5)
            .backwardOutgoingOpacity(null, 1, 0);

        return result;
    }

    public static JPageComponentAnimation verticalFadeAndShrink()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingTranslate(null, 0, 0, 1, 0).forwardIncomingScale(null, 2, 1, 2, 1)
            .forwardIncomingOpacity(null, 0, 1);
        result.forwardOutgoingTranslate(null, 0, 0, 0, -0.5).forwardOutgoingScale(null, 1, 0.5, 1, 0.5)
            .forwardOutgoingOpacity(null, 1, 0);

        result.backwardIncomingTranslate(null, 0, 0, -1, 0).backwardIncomingScale(null, 2, 1, 2, 1)
            .backwardIncomingOpacity(null, 0, 1);
        result.backwardOutgoingTranslate(null, 0, 0, 0, 0.5).backwardOutgoingScale(null, 1, 0.5, 1, 0.5)
            .backwardOutgoingOpacity(null, 1, 0);

        return result;
    }

    public static JPageComponentAnimation horizontal()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingTranslate(null, 1, 0, 0, 0).forwardOutgoingTranslate(null, 0, -1, 0, 0);
        result.backwardIncomingTranslate(null, -1, 0, 0, 0).backwardOutgoingTranslate(null, 0, 1, 0, 0);

        return result;
    }

    public static JPageComponentAnimation vertical()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingTranslate(null, 0, 0, 1, 0).forwardOutgoingTranslate(null, 0, 0, 0, -1);
        result.backwardIncomingTranslate(null, 0, 0, -1, 0).backwardOutgoingTranslate(null, 0, 0, 0, 1);

        return result;
    }

    public static JPageComponentAnimation rotateTop()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingRotate(null, 0, 1, Math.PI / 2, 0).forwardOutgoingRotate(null, 0, 1, 0, -Math.PI / 2);
        result.backwardIncomingRotate(null, 0, 1, -Math.PI / 2, 0).backwardOutgoingRotate(null, 0, 1, 0, Math.PI / 2);

        return result;
    }

    public static JPageComponentAnimation rotateBottom()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingRotate(null, 0, -1, -Math.PI / 2, 0).forwardOutgoingRotate(null, 0, -1, 0, Math.PI / 2);
        result.backwardIncomingRotate(null, 0, -1, Math.PI / 2, 0).backwardOutgoingRotate(null, 0, -1, 0, -Math.PI / 2);

        return result;
    }

    public static JPageComponentAnimation rotateLeft()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingRotate(null, 1, 0, -Math.PI / 2, 0).forwardOutgoingRotate(null, 1, 0, 0, Math.PI / 2);
        result.backwardIncomingRotate(null, 1, 0, Math.PI / 2, 0).backwardOutgoingRotate(null, 1, 0, 0, -Math.PI / 2);

        return result;
    }

    public static JPageComponentAnimation rotateRight()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingRotate(null, -1, 0, Math.PI / 2, 0).forwardOutgoingRotate(null, -1, 0, 0, -Math.PI / 2);
        result.backwardIncomingRotate(null, -1, 0, -Math.PI / 2, 0).backwardOutgoingRotate(null, -1, 0, 0, Math.PI / 2);

        return result;
    }

    public static JPageComponentAnimation newspaper()
    {
        JPageComponentTransitionAnimation result = new JPageComponentTransitionAnimation();

        result.forwardIncomingTranslate(null, 0.5, 0, -0.5, 0).forwardIncomingRotate(null, 0, 0, Math.PI * 16, 0)
            .forwardIncomingScale(Interpolations.accelerating(), 1d / 16, 1, 1d / 16, 1)
            .forwardIncomingOpacity(null, 0, 1);
        result.forwardOutgoingTranslate(Interpolations.accelerating(), 0, 0, 0, 0.5)
            .forwardOutgoingRotate(Interpolations.accelerating(), 0, 0, 0, Math.PI / 8)
            .forwardOutgoingOpacity(null, 1, 0);

        result.backwardIncomingTranslate(null, -0.5, 0, -0.5, 0).backwardIncomingRotate(null, 0, 0, Math.PI * 16, 0)
            .backwardIncomingScale(Interpolations.accelerating(), 1d / 16, 1, 1d / 16, 1)
            .backwardIncomingOpacity(null, 0, 1);
        result.backwardOutgoingTranslate(Interpolations.accelerating(), 0, 0, 0, 0.5)
            .backwardOutgoingRotate(Interpolations.accelerating(), 0, 0, 0, -Math.PI / 8)
            .backwardOutgoingOpacity(null, 1, 0);

        return result;
    }
}
